package com.kgame5.xtank3d.model.shot {
	import com.kgame5.xtank3d.effect.Eff3DManager;
import kgame5.enginex.EntityVO;
import kgame5.enginex.enum.Layer3DEnum;
import kgame5.enginex.part.GViewComp;
import kgame5.k3d.core.obj3d.node3d.Node3D;

import com.kgame5.xtank3d.resource.ResourceManagerX;
import com.kgame5.xtank3d.vo.ShotVO;

/**
 * @author kk
 */
public class ShotViewComp extends GViewComp{
	
	private var md:Node3D;
	private var vo:ShotVO;
	public function ShotViewComp(vo:ShotVO){
		this.vo=vo;
		//shotVO.type
		md=ResourceManagerX.getInstance().getCannonShot(vo);
		md.layerID = Layer3DEnum.LAYER_MAIN;//千万要加上这
		
		//影子
		md_shadow=ResourceManagerX.getInstance().getShadow(vo.hardVO.bball.R);
		md_shadow.layerID=Layer3DEnum.LAYER_SHADOW;
	}

	override public function getNode3D():Node3D{
		return md;
	}
	
	override public function update(_vo:EntityVO):void{
		
		super.update(_vo);//影子
		
		//整体
		md.ti.hardVO.v3d_p.copy(vo.hardVO.v3d_p);//位置
		md.rotY = vo.hardVO.v3d_r.y;//旋转
		
		//烟雾
		smoke();
	}

	override public function dispose():void{
		
	}
	
	private var smokeTick:int;
	private function smoke():void{
		smokeTick++;
		if(smokeTick>1){
			smokeTick=0;
			Eff3DManager.getInstance().shotSmoke(vo);
		}
	}
}
}
